<?php
/**
 * Created by PhpStorm.
 * User: andrei
 * Date: Jun 28, 2012
 * Time: 3:23:35 PM
 * To change this template use File | Settings | File Templates.
 */
 
class Db_Products_Sizes extends Common {
	protected static $tableName = TAB_SIZES;
	protected static $dbFields = array(
        'id',
		's_width',
		's_height',
		's_name',
		's_face_number',
        's_orientation',
        'deleted'
	);
	/**
	 * @var Db_Products_Sizes
	 */
	public $objectArray;

	public $id;
	public $s_width;
	public $s_height;
	public $s_name;
	public $s_face_number;
    public $s_orientation;
    public $deleted;

    function __construct($value=NULL, $fieldName=NULL) {
        parent::__construct($value, $fieldName);
    }

    /**
     * return all used and not used Sizes
     * @return mixed
     */
    public static function getAllSizes() {
        $sql = 'SELECT *, `t`.`id` AS `t_id`, `s`.`id` AS `s_id` FROM ?f AS `s`
                LEFT JOIN ?f AS `t` ON `t`.`t_size_id` = `s`.`id` AND `t`.`deleted` = 0
                WHERE `s`.`deleted` = 0 GROUP BY `s`.`id` ;';

        return self::$DB->select($sql, self::$tableName, TAB_TEMPLATES);
    }

}